<script setup>
import {ref} from "vue";
import {showToast} from "vant";
// import { areaList } from '@vant/area-data';
import axios from "axios";
import { useRouter } from 'vue-router'
const router = useRouter()

const searchResult = ref([]);

const onSave = () => showToast(
    axios({
      method:'get',
      url:'http://localhost:8081/api/order/orderListUpdate',
    }).then((data) => {
      console.log(JSON.stringify(data))
      console.log("获取处理器的数据：" + JSON.stringify(data.data))
      var r = data.data;

      // 加载状态结束
      loading.value = false;
      finished.value = true

      if (r.code == 0) {
        showToast("修改成功");
        notifications.value = r.data;// 初始化界面

      } else {
        showToast("修改失败");
      }
    })
);
const onDelete = () => showToast(axios({
      method:'get',
      url:'http://localhost:9094/order/orderListDelate',
    }).then((data) => {
      console.log(JSON.stringify(data))
      console.log("获取处理器的数据：" + JSON.stringify(data.data))
      var r = data.data;

      // 加载状态结束
      loading.value = false;
      finished.value = true

      if (r.code == 0) {
        showToast("删除成功");
        notifications.value = r.data;// 初始化界面

      } else {
        showToast("删除失败");
      }
    })
);


const onChangeDetail = (val) => {

}

const onClickLeft1 = () => {
  router.push('/orderDetail')
 }


</script>

<template>
<h1>我叫喻文波</h1>
  <van-nav-bar
      title="我的消息"
      left-text="返回"
      left-arrow
      @click-left="onClickLeft1"
  />
  <van-address-edit
      :area-list="areaList"
      show-delete
      show-set-default
      show-search-result
      :search-result="searchResult"
      :area-columns-placeholder="['请选择', '请选择', '请选择']"
      @save="onSave"
      @delete="onDelete"
      @change-detail="onChangeDetail"
  />
</template>

<style scoped>

</style>